package iosr11.example;

import iosr11.Service.MarkService;
import iosr11.Service.ServiceLocatorImpl_old;
import iosr11.Service.StudentService;
import iosr11.Service.TeacherService;
import iosr11.data.Mark;
import iosr11.data.Student;
import iosr11.data.Teacher;

import java.text.DateFormat;
import java.util.Calendar;

public class MarkServiceMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		/*
		MarkService markS = (MarkService) ServiceLocatorImpl_old.getInstance().getService(Mark.class);
		TeacherService techS = (TeacherService) ServiceLocatorImpl_old.getInstance().getService(Teacher.class);
		StudentService studS = (StudentService) ServiceLocatorImpl_old.getInstance().getService(Student.class);
		/*
		Teacher t1 =techS.getTeacher("teacher1@gmail.com");
		System.out.println(t1);
		Student s1 =studS.getStudent("anton.k@gmail.com");
		System.out.println(s1);
		
		Mark mark = new Mark();
		mark.setDate(Calendar.getInstance());
		mark.setGrade(5.0f);
		mark.setKind(null);
		mark.setPoints(100);
		
		System.out.println(markS.addMark(s1, t1, mark));

		*/
		System.out.println(DateFormat.getInstance().getCalendar().getTime());
		System.out.println(Calendar.getInstance().getTime());
		/*
		Teacher te = techS.getTeacher("Jacek Król");
		System.out.println(te);
		
		List<Student> lista = studS.getAllStudents();
		System.out.println(lista);
		/*
		for (Student st : lista){
		
		Random randomGenerator2 = new Random();
		for (int i = 1; i <= 3; ++i){
			int randomInt2 = randomGenerator2.nextInt(100);
			//System.out.println("Generated2 : " + ((randomInt2%2)) );
			Random randomGenerator = new Random();
			for (int idx = 1; idx <= 3; ++idx){
				int randomInt = randomGenerator.nextInt(100);
				randomInt = ((randomInt%4)+2);
				System.out.println("Generated : " + randomInt );			
				Mark mark = new Mark();
				Date date = new Date();
				date.setTime(Calendar.getInstance().getTimeInMillis());
				mark.setDate(date);
				mark.setTeacher(te);
				mark.setStudent(st);
				mark.setGrade((float) randomInt);
				
				if (randomInt2==0)
					mark.setKind(MarkKind.CREDIT);
				else if (randomInt2==1)
					mark.setKind(MarkKind.EXAM);
				else 
					mark.setKind(MarkKind.PROJECT);
				mark.setPoints(mark.getGrade()*5f);
				//System.out.println("===============Dodaje dla: "+st.getName());
				//System.out.println(markS.createMark(st, te, mark));
			}
		}
		}
// */
		/*
		Student s2 =studS.getStudent("Tadeusz Kras");
		System.out.println(s2);
		
		Teacher te = techS.getTeacher("Jacek Król");
		System.out.println(te);
		
		Mark mark = new Mark();
		Date date = new Date();
		date.setTime(Calendar.getInstance().getTimeInMillis());
		mark.setDate(date);
		mark.setGrade(5f);
		mark.setKind(MarkKind.EXAM);
		mark.setPoints(30f);
		//mark.setStudent(s2);
		//mark.setTeacher(te);
		
		System.out.println(markS.createMark(s2, te, mark));
		System.out.println(mark);*/
	}

}
